#define _CRT_SECURE_NO_WARNINGS 0
#include <iostream>
using namespace std;

class Date
{
    friend istream& operator>>(istream& in, Date& d);
    friend ostream& operator<<(ostream& out, const Date& d);
public:
    Date(int year = 2000)
        :_year(year)
    {}

    int GetMonthDay(int year, int month)
    {
        int monthday[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
        {
            return 29;
        }
        return monthday[month];
    }

    Date& operator+=(int day);


private:
    int _year;
    int _month = 1;
    int _day = 1;
};

istream& operator>>(istream& in, Date& d)
{
    in >> d._year >> d._month >> d._day;
    return in;
}

ostream& operator<<(ostream& out, const Date& d)
{
    printf("%04d-%02d-%02d\n", d._year, d._month, d._day);
    return out;
}

Date& Date::operator+=(int day)
{
    _day += day;
    while (_day > GetMonthDay(_year, _month))
    {
        _day -= GetMonthDay(_year, _month);
        ++_month;
        if (_month == 13)
        {
            _year++;
            _month = 1;
        }
    }
    return *this;
}

int main()
{
    int year, afterDay;

    while (scanf("%d%d", &year, &afterDay) != EOF)
    {
        Date d(year);
        d += afterDay;

        cout << d;
    }

    return 0;
}

